import { postLoginWxminSimple } from "@/http/profile";
import { getMembeProfile } from "@/http/profile";
export default {
    // 命名空间
    namespaced: true,
    state: {
        //  用户信息
        profile: null,
        // 会员信息 单独请求接口 返回
        memberProfile: null,
    },
    getters: {},
    mutations: {
        setProfile(state, payload) {
            state.profile = payload;
        },
        setMemberProfile(state, payload) {
            state.memberProfile = payload;
            console.log(555, state.memberProfile);
        },
    },

    actions: {
        // 异步执行登录 获取用户信息
        async fetchProfile({ commit }, data) {
            // console.log(444, 111);

            const result = await postLoginWxminSimple(data);
            commit("setProfile", result.result);
            // console.log(333, result);
        },
        // 异步 获取会员信息
        async fetchMemberProfile({ commit }) {
            console.log(34);
            const result = await getMembeProfile();
            console.log(444, result);
            // const reslu 0 rasehj get maebbver 
            // 异步获取会员信息

            commit("setMemberProfile", result.result);
            return result.result;
            // this./setData({
            // })
        },
    },
};